package pl.shenlon.ga;

import java.util.Random;

import pl.shenlon.poker.game.GameState;
import pl.shenlon.poker.game.PlayerAction;
import pl.shenlon.poker.game.PlayerActionType;
import pl.shenlon.poker.game.PokerPlayer;
import pl.shenlon.poker.game.gametypes.PokerGame;

public class GeneticPokerPlayer extends PokerPlayer {
	
	public static final Random rnd;

	static {
		rnd = new Random();
	}
	
	private Specimen specimen;

	public GeneticPokerPlayer(int cash) {
		super(cash);
	}

	public GeneticPokerPlayer(int cash, Specimen specimen) {
		super(cash);
		this.specimen = specimen;
	}

	@Override
	public PlayerAction act(PokerGame game,
			PlayerActionType... allowedActionTypes) {
		GameState gameState = new GameState(game, this);
		BehaviourPattern pattern = specimen.getGenom().getBehaviourPattern(
				gameState);
		return new PlayerAction(pattern.getAction(allowedActionTypes),
				gameState);
	}

	public Specimen getSpecimen() {
		return specimen;
	}

	public void setSpecimen(Specimen specimen) {
		this.specimen = specimen;
	}
}